<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改角色')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-role-edit" th:object="${obj}">
			<input id="id" name="id" type="hidden" th:value="*{id}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label ">所属步道：</label>
				<div class="col-sm-8">
					<input class="form-control" type="number" name="trail_id" id="trail_id" th:value="*{trail_id}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">排行榜唯一编号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="imei" id="imei" th:value="*{imei}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">所在位置：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="site" id="site" th:value="*{site}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">排行榜状态：</label>
				<div class="col-sm-8">
					<div class="radio-box">
						<input type="radio" id="statushide" required name="status" value="1" th:checked="*{status==1}" >
						<label for="1">在线</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="statusshow" required name="status" value="2" th:checked="*{status==2}">
						<label for="2">离线</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">数据代码：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="code" id="code" th:value="*{code}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control" th:text="*{remark}"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
	$.fn.serializeObject = function() {
		var o = {};
		var a = this.serializeArray();
		$.each(a, function() {
			if (o[this.name]) {
				if (!o[this.name].push) {
					o[this.name] = [ o[this.name] ];
				}
				o[this.name].push(this.value || '');
			} else {
				o[this.name] = this.value || '';
			}
		});
		return o;
	};
	
		function edit() {
			var formdata = $("#form-role-edit").serializeObject();
			$.ajax({
				cache : true,
				type : "POST",
				contentType : "application/json; charset=utf-8",
				url : "save",
				data : JSON.stringify(formdata),
				async : false,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					$.operate.successCallback(data);
				}
			});
		}
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }
	</script>
</body>
</html>
